<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>收录电影网址管理页面</title>
<link rel="stylesheet" type="text/css" href="/static/jquery-easyui-1.3.3/themes/default/easyui.css" />
<link rel="stylesheet" type="text/css" href="/static/jquery-easyui-1.3.3/themes/icon.css" />
<script type="text/javascript" src="/static/jquery-easyui-1.3.3/jquery.min.js"></script>
<script type="text/javascript" src="/static/jquery-easyui-1.3.3/jquery.easyui.min.js"></script>
<script type="text/javascript" src="/static/jquery-easyui-1.3.3/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript">

	var url;
	
	function searchWebSite(){
		$("#dg").datagrid("load",{
			"name":$("#s_name").val(),
			"url":$("#s_url").val()
		});
	}
	
	function openWebSiteAddDialog(){
		$("#dlg").dialog("open").dialog("setTitle","添加收录电影网址信息");
		url="/admin/webSite/save";
	}
	
	function openWebSiteModifyDialog(){
		var selectedRows=$("#dg").datagrid("getSelections");
		if(selectedRows.length!=1){
			$.messager.alert("系统提示","请选择一条要编辑的数据！");
			return;
		}
		var row=selectedRows[0];
		$("#fm").form("load",row);
		$("#dlg").dialog("open").dialog("setTitle","编辑收录电影网址信息");
		url="/admin/webSite/save?id="+row.id;
	}
	
	function deleteWebSite(){
		var selectedRows=$("#dg").datagrid("getSelections");
		if(selectedRows.length==0){
			$.messager.alert("系统提示","请选择要删除的数据！");
			return;
		}
		var strIds=[];
		for(var i=0;i<selectedRows.length;i++){
			strIds.push(selectedRows[i].id);
		}
		var ids=strIds.join(",");
		$.messager.confirm("系统提示","您确定要删除这<font color=red>"+selectedRows.length+"</font>条数据吗？",function(r){
			if(r){
				$.post("/admin/webSite/delete",{ids:ids},function(result){
					if(result.success){
						$.messager.alert("系统提示","数据已成功删除！");
						$("#dg").datagrid("reload");
					}else{
						$.messager.alert("系统提示",result.errorInfo);
					}
				},"json");
			}
		});
	}
	
	function saveWebSite(){
		$("#fm").form("submit",{
			url:url,
			onSubmit:function(){
				return $(this).form("validate");
			},
			success:function(result){
				var result=eval('('+result+')');
				if(result.success){
					$.messager.alert("系统提示","保存成功！");
					resetValue();
					$("#dlg").dialog("close");
					$("#dg").datagrid("reload");
				}
			}
		});
	}
	
	function resetValue(){
		$("#name").val("");
		$("#url").val("");
	}
	
	function closeWebSiteDialog(){
		resetValue();
		$("#dlg").dialog("close");
	}
	

</script>
</head>
<body style="margin: 1px">
<table id="dg" title="收录电影网址管理" class="easyui-datagrid" 
   fitColumns="true" pagination="true" rownumbers="true" 
   url="/admin/webSite/list" fit="true" toolbar="#tb">
	<thead>
		<tr>
			<th field="cb" checkbox="true" align="center"></th>
			<th field="id" width="20" align="center">编号</th>
			<th field="name" width="200" align="center">网站名称</th>
			<th field="url" width="200" align="center">网站地址</th>
		</tr>
	</thead>
</table>
<div id="tb">
  <div>
	<a href="javascript:openWebSiteAddDialog()" class="easyui-linkbutton" iconCls="icon-add" plain="true">添加</a>
	<a href="javascript:openWebSiteModifyDialog()" class="easyui-linkbutton" iconCls="icon-edit" plain="true">修改</a>
	<a href="javascript:deleteWebSite()" class="easyui-linkbutton" iconCls="icon-remove" plain="true">删除</a>
  </div>
  <div>
  	&nbsp;电影网站名称：&nbsp;<input type="text" id="s_name" size="20" onkeydown="if(event.keyCode==13) searchWebSite()"/>
  	&nbsp;电影网站地址：&nbsp;<input type="text" id="s_url" size="20" onkeydown="if(event.keyCode==13) searchWebSite()"/>
  	<a href="javascript:searchWebSite()" class="easyui-linkbutton" iconCls="icon-search" plain="true">搜索</a>
  </div>
</div>

<div id="dlg" class="easyui-dialog" style="width: 500px;height: 180px;padding: 10px 20px"
   closed="true" buttons="#dlg-buttons">
	<form id="fm" method="post">
		<table cellspacing="8px">
			<tr>
				<td>电影网站名称：</td>
				<td>
					<input type="text" id="name" name="name" class="easyui-validatebox" required="true"/>
				</td>
			</tr>
			<tr>
				<td>电影网站地址：</td>
				<td>
					<input type="text" id="url" name="url" class="easyui-validatebox" validtype="url" required="true"/>
				</td>
			</tr>
		</table>
	</form>
</div>
<div id="dlg-buttons">
	<a href="javascript:saveWebSite()" class="easyui-linkbutton" iconCls="icon-ok" >保存</a>
	<a href="javascript:closeWebSiteDialog()" class="easyui-linkbutton" iconCls="icon-cancel" >关闭</a>
</div>
</body>
</html>